import java.util.ArrayList;
import java.util.List;

/**
 * 1748. 唯一元素的和
 * https://leetcode-cn.com/problems/sum-of-unique-elements/
 */
public class Solutions_1748 {
    public static void main(String[] args) {
        int[] nums1 = {1, 2, 3, 2};  // output: 4
        int[] nums2 = {1, 1, 1, 1, 1};  // output: 0
        int[] nums3 = {1, 2, 3, 4, 5};  // output: 15

        List<int[]> inputs = new ArrayList<>();
        inputs.add(nums1);
        inputs.add(nums2);
        inputs.add(nums3);

        for (int[] input : inputs) {
            int result = sumOfUnique(input);
            System.out.println(result);
        }
    }

    public static int sumOfUnique(int[] nums) {
        int[] counts = new int[101];
        for (int num : nums) {
            counts[num] ++;
        }
        int sum = 0;
        for (int i = 0; i < counts.length; i++) {
            if (counts[i] == 1) {
                sum += i;
            }
        }
        return sum;
    }
}
